package com.lite.haru.alarmpolice.activity;

import org.kymjs.kjframe.KJActivity;
import org.kymjs.kjframe.KJBitmap;
import org.kymjs.kjframe.ui.BindView;
import org.kymjs.kjframe.ui.ViewInject;
import org.kymjs.kjframe.widget.ScaleImageView;

import android.annotation.SuppressLint;
import android.app.ProgressDialog;
import android.os.Handler;
import android.os.Message;
import android.view.View;

import com.lite.haru.R;
import com.lite.haru.constant.Constant;

public class PhotoAty extends KJActivity {

	KJBitmap kjb;
	private ProgressDialog dialog;
	String alarmwork;

	@BindView(id = R.id.photo)
	private ScaleImageView photo;

	@Override
	public void setRootView() {
		setContentView(R.layout.aty_photo);
	}

	@Override
	public void initData() {
		kjb = new KJBitmap();
		alarmwork = getIntent().getStringExtra("alarmwork");
		// Thread thread = new Thread(new Runnable() {
		//
		// @Override
		// public void run() {
		//
		// if (!alarmwork.equals("")) {
		// Message message = new Message();
		// message.what = 0;
		// mHandler.sendMessage(message);
		// } else {
		// Message message = new Message();
		// message.what = 1;
		// mHandler.sendMessage(message);
		//
		// }
		// }
		// });
		// thread.start();
		super.initData();
	}

	@Override
	public void initWidget() {
		super.initWidget();
		// dialog = ProgressDialog.show(this, "获取图片", "图片获取中请稍候(oﾟvﾟ)ノ");

		if (!alarmwork.equals("")) {
			photo.setVisibility(View.VISIBLE);
			photo.setCanDoubleClick(true);
			photo.setCanRotate(true);
			kjb.display(photo, Constant.url + "/" + alarmwork);
			// dialog.dismiss();
		} else {
			ViewInject.toast("没获取到图片");
		}

	}

	@SuppressLint("HandlerLeak")
	private Handler mHandler = new Handler() {

		public void handleMessage(android.os.Message msg) {
			if (msg.what == 0) {
				dialog.dismiss();// 获取到数据
			}
			if (msg.what == 1) {
				dialog.dismiss();// 没有获取到数据
			}
		};
	};

}
